package io.noties.markwon.base.html.jsoup.parser

/**
 * A Parse Error records an error in the input HTML that occurs in either the tokenisation or the tree building phase.
 */
class ParseError {
    /**
     * Retrieves the offset of the error.
     * @return error offset within input
     */
    var position: Int
        private set

    /**
     * Retrieve the error message.
     * @return the error message.
     */
    var errorMessage: String
        private set

    internal constructor(pos: Int, errorMsg: String) {
        position = pos
        errorMessage = errorMsg
    }

    internal constructor(pos: Int, errorFormat: String?, vararg args: Any?) {
        errorMessage = String.format(errorFormat!!, *args)
        position = pos
    }

    override fun toString(): String {
        return position.toString() + ": " + errorMessage
    }
}